#include "CMainMenuState.h"
#include "CGameClass.h"
#include "CGamePlayState.h"
#include "CSGD_DirectInput.h"
#include "CSGD_FModManager.h"
#include "testenum.h"
#include <iostream>
using std::cout;

CMainMenuState CMainMenuState::Instance;

void CMainMenuState::Enter()
{
	m_pDI = CSGD_DirectInput::GetInstance();
	tex =  CTextureManager::GetInstance()->LoadTexture("img/splash.tga");
	shape.MakeShape(Vec2(-20,-19.5f),Vec2(20,19.5f),1);

	//Sun =  CTextureManager::GetInstance()->LoadTexture("img/splashSun.tga");
	//SunDude.MakeShape(Vec2(-5,-5),Vec2(5,5),1);

	//Cloud = CTextureManager::GetInstance()->LoadTexture("img/splashCloud.tga");
	//CloudDude.MakeShape(Vec2(-5,-5),Vec2(5,5),1);

#if LOADSFX
	cout << "Load BG SFX Menu file\n";
	m_nBG_SFX_ID = CSGD_FModManager::GetInstance()->LoadSound( "sfx/AiMRainFX.mp3", SGD_FMOD_LOOPING);
	CSGD_FModManager::GetInstance()->PlaySound( m_nBG_SFX_ID );
	CSGD_FModManager::GetInstance()->SetVolume( m_nBG_SFX_ID, .5f );
	cout << "Made it\n";
#endif LOADSFX

}

void CMainMenuState::Update(float dt)
{

}

void CMainMenuState::Render()
{
	CRender::GetInstance()->DrawTex(tex, &shape, Vec2(0, 0), -1);
	//CRender::GetInstance()->DrawTex(Sun, &SunDude, Vec2(0, 0), 0);
	//CRender::GetInstance()->DrawTex(Cloud, &CloudDude, Vec2(0, 0), 0);

}
void CMainMenuState::Input()
{
	if(m_pDI->KeyDown(DIK_SPACE))
	{
		CGameClass::GetInstance()->ChangeState(CGamePlayState::GetInstance());
	}
}
void CMainMenuState::Exit()
{
	CTextureManager::GetInstance()->ReleaseAll();
	#if LOADSFX
	CSGD_FModManager::GetInstance()->StopSound( m_nBG_SFX_ID );
	CSGD_FModManager::GetInstance()->UnloadSound( m_nBG_SFX_ID );
	#endif LOADSFX
}
bool CMainMenuState::LoadPicturesFromFile(const char* filename)
{

	//std::fstream fin(filename, std::ios_base::in );

	//if( !fin.is_open() )
	//{
	//	messagebox( 0, "error loading pictures", "error loading pictures", 0 );
	//	return false;
	//}

	//// keep loading pictures till end of file
	//std::string pic_filename;

	//getline( fin, pic_filename );
	//m_ntextureids[tex_player] = m_ptm->loadtexture( pic_filename.c_str() );
	//getline( fin, pic_filename );
	//m_ntextureids[tex_cloud] = m_ptm->loadtexture( pic_filename.c_str() );

	//fin.close();
	//fin.clear();


	return true;
}